package com.stone.swing.kit;

import java.io.InputStream;
import java.util.Arrays;

import org.apache.http.Header;
import org.apache.http.ProtocolVersion;

public class HttpResponsePojo {
	private int statusCode;
	private String reasonPhrase;
	private ProtocolVersion version;
	private String stringEntity;
	private byte[] byteEntity;
	private InputStream inputStream;
	private ReturnType returnType;
	private boolean repeatable;

	private boolean chunked;

	private long contentLength;

	private Header contentType;

	private Header contentEncoding;

	boolean isStreaming;

	public HttpResponsePojo( int statusCode, String reasonPhrase, ProtocolVersion version ) {
		this.statusCode = statusCode;
		this.reasonPhrase = reasonPhrase;
		this.version = version;
	}

	public boolean isSuccess() {
		if ( this.getStatusCode() == 200 ) {
			return true;
		}
		return false;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public boolean isRepeatable() {
		return repeatable;
	}

	public void setRepeatable( boolean repeatable ) {
		this.repeatable = repeatable;
	}

	public boolean isChunked() {
		return chunked;
	}

	public void setChunked( boolean chunked ) {
		this.chunked = chunked;
	}

	public long getContentLength() {
		return contentLength;
	}

	public void setContentLength( long contentLength ) {
		this.contentLength = contentLength;
	}

	public Header getContentType() {
		return contentType;
	}

	public void setContentType( Header contentType ) {
		this.contentType = contentType;
	}

	public Header getContentEncoding() {
		return contentEncoding;
	}

	public void setContentEncoding( Header contentEncoding ) {
		this.contentEncoding = contentEncoding;
	}

	public boolean isStreaming() {
		return isStreaming;
	}

	public void setStreaming( boolean isStreaming ) {
		this.isStreaming = isStreaming;
	}

	public String getStringEntity() {
		return stringEntity;
	}

	public void setStringEntity( String stringEntity ) {
		this.stringEntity = stringEntity;
	}

	public byte[] getByteEntity() {
		return byteEntity;
	}

	public void setByteEntity( byte[] byteEntity ) {
		this.byteEntity = byteEntity;
	}

	public enum ReturnType {
		STRING, BYTE, INPUTSTREM
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream( InputStream inputStream ) {
		this.inputStream = inputStream;
	}

	public ReturnType getReturnType() {
		return returnType;
	}

	public void setReturnType( ReturnType returnType ) {
		this.returnType = returnType;
	}

	public String getReasonPhrase() {
		return reasonPhrase;
	}

	public ProtocolVersion getVersion() {
		return version;
	}

	@Override
	public String toString() {
		return "HttpResponsePojo [statusCode=" + statusCode + ", reasonPhrase=" + reasonPhrase + ", version=" + version
				+ ", stringEntity=" + stringEntity + ", byteEntity=" + Arrays.toString(byteEntity) + ", inputStream="
				+ inputStream + ", returnType=" + returnType + ", repeatable=" + repeatable + ", chunked=" + chunked
				+ ", contentLength=" + contentLength + ", contentType=" + contentType + ", contentEncoding="
				+ contentEncoding + ", isStreaming=" + isStreaming + "]";
	}


}
